// 遍历树节点
const three = (data)=>{
  let arr = []
  data?.forEach(item=>{
    const threeData = { ...item.self, disabled: false }
    if (item.children) threeData.children = three(item.children)
    arr.push(threeData)
  })
  return arr
}

// 树节搜索
const searchTree = (data, keyword) =>{
  let results = [];
  data.forEach(function (item) {
    if (item.name.includes(keyword)) {
      results.push(item);
    }
    if (item.children && item.children.length > 0) {
      let childResults = searchTree(item.children, keyword);
      results = results.concat(childResults);
    }
  });
  return results;
}


export {
  three,
  searchTree
}
